package a01_Thread;

/**
 * @Author quan
 * @Description 使用多个不同的runnable接口
 * @Date 2023/4/26 10:43
 */
public class Demo3_multiRunnable {
    public static void main(String[] args) {
        //创建任务的对象
        MyRunnable1 myrunnable1 = new MyRunnable1();
        MyRunnable2 myrunnable2 = new MyRunnable2();
        //创建生产皮包的线程
        Thread t1 = new Thread(myrunnable1);
        Thread t2 = new Thread(myrunnable1);
        //创建生产皮鞋的线程
        Thread t3 = new Thread(myrunnable2);
        //启动线程
        t1.start();
        t2.start();
        t3.start();
    }
}
//描述生产皮包的任务
class MyRunnable1 implements Runnable{
    @Override
    public void run() {
        System.out.println("生产皮包，金币+1");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
//描述生产皮鞋的任务
class MyRunnable2 implements Runnable{
    @Override
    public void run() {
        System.out.println("生产皮鞋，金币+1");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
